package com.llc.gulimall.order.listener;

import com.llc.gulimall.order.entity.OrderEntity;
import com.llc.gulimall.order.service.OrderService;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * @author llc
 * @Description
 * @Version
 * @date 2022/2/17 22:56
 */
//@RabbitListener(queues = "order.release.order.queue")
//@Service
//public class OrderCloseListener {
//    @Autowired
//    OrderService orderService;
//    @RabbitHandler
//    public void listener(OrderEntity entity, Channel channel, Message message) throws IOException {
//        System.out.println("收到过期的订单消息,准备关闭订单" + entity);
//        try {
//            orderService.closeOrder(entity);
//            System.out.println("关闭订单");
//            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
//            System.out.println("成功");
//        } catch (Exception e) {
//            channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
//        }
//    }
//}
